import $ from '../common';
Page({
  data: {
    titleHeight: $.gData().titleHeight,
    statuHeight: $.gData().statuHeight,
    info: {
      funtit: '暂无需要布置作业的班级',
      tiptit: '请选择需要布置作业的班级',
      id: 2
    },
    page: 1,
    tip:'下拉加载更多',
    classinfo:[]
  },
  onReachBottom(){
    console.log('触底了！！！');
    this.getinfo()
  },
  getinfo() {
    const {page,classinfo}=this.data
    $.get('/teacher/groups', {
      limit:20,
      page
    }, res => {
      if(res.groups.length==20){
        this.data.tip='下拉加载更多了'
      }else{
        this.data.tip='已经到底了'
      }
      this.data.page++
      this.setData({
        classinfo:[...classinfo,...res.groups],
        tip:this.data.tip
      })
    })
  },
  itemclick(tmp) {
    $.navigateTo(`/classaboutPart/homewdetail?group_uuid=${tmp.detail}`)
  },
  onLoad(e) {
    this.getinfo()
  },
  onShow() {}
})